package com.example.fitapp.activity.adapter;

import android.app.Application;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.example.fitapp.activity.R;
import com.example.fitapp.activity.activity.MyApplication;
import com.example.fitapp.activity.bean.DynamicInfo;
import com.example.fitapp.activity.bean.HomeDetail;
import com.example.fitapp.activity.bean.MySerializable;

import java.util.ArrayList;
import java.util.List;

public class HomeDetailAdapter extends RecyclerView.Adapter<HomeDetailAdapter.ViewHolder> {

    private List<DynamicInfo.DataBean.ImagesBean> myimageList = new ArrayList<>();

    public class ViewHolder extends RecyclerView.ViewHolder {
        ImageView imageView;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.detail_img);
        }
    }

    public HomeDetailAdapter(List<DynamicInfo.DataBean.ImagesBean> imageList){
        myimageList = imageList;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_home_detail_item,parent,false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

        Glide.with(MyApplication.getContext()).load(myimageList.get(position).getImage()).transition(new DrawableTransitionOptions().crossFade()).into(holder.imageView);
    }

    @Override
    public int getItemCount() {
        return myimageList.size();
    }


}
